/****** Object:  StoredProcedure [dbo].[aspnet_Users_CreateUser]    Script Date: 10/12/2011 14:24:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO

--Modificacion de la tabla de usuarios para guardar el nombre y apellido
ALTER TABLE aspnet_Users ADD FirstName nVarchar(256) NULL, LastName nVarChar(256) NULL
GO

--Modificacion al sp para almacenar el nombre y apellido del usuario
ALTER PROCEDURE [dbo].[aspnet_Users_CreateUser]
    @ApplicationId    uniqueidentifier,
    @UserName         nvarchar(256),
    @IsUserAnonymous  bit,
    @LastActivityDate DATETIME,
    @FirstName        nvarchar(256),
    @LastName         nvarchar(256),
    @UserId           uniqueidentifier OUTPUT
AS
BEGIN
    IF( @UserId IS NULL )
        SELECT @UserId = NEWID()
    ELSE
    BEGIN
        IF( EXISTS( SELECT UserId FROM dbo.aspnet_Users
                    WHERE @UserId = UserId ) )
            RETURN -1
    END

    INSERT dbo.aspnet_Users (ApplicationId, UserId, UserName, LoweredUserName, IsAnonymous, LastActivityDate, FirstName, LastName)
    VALUES (@ApplicationId, @UserId, @UserName, LOWER(@UserName), @IsUserAnonymous, @LastActivityDate, @FirstName, @LastName)

    RETURN 0
END
